package com.tianji.learning.controller;


import com.tianji.common.domain.dto.PageDTO;
import com.tianji.learning.domain.dto.ReplyDTO;
import com.tianji.learning.domain.query.ReplyPageQuery;
import com.tianji.learning.domain.vo.ReplyVO;
import com.tianji.learning.service.IInteractionReplyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 互动问题的回答或评论 前端控制器
 * </p>
 *
 * @author hzy
 * @since 2023-09-09
 */
@RestController
@RequestMapping("/replies")
@Api(tags = "回答或评论接口")
@Slf4j
@RequiredArgsConstructor
public class InteractionReplyController {

    private final IInteractionReplyService replyService;

    /**
     * 新增回答或评论
     *
     * @param dto
     */
    @ApiOperation("新增回答或评论")
    @PostMapping
    public void insertReply(@RequestBody ReplyDTO dto) {
        replyService.insertReply(dto);
    }

    /**
     * 分页查询回答和评论列表
     *
     * @param pageQuery
     * @return
     */
    @ApiOperation("分页查询回答和评论列表")
    @GetMapping("/page")
    public PageDTO<ReplyVO> selectPageQuestions(@Validated ReplyPageQuery pageQuery) {
        return replyService.selectPageQuestions(pageQuery);
    }
}
